<template>
  <div>
         <el-form
      :model="formData"
      inline
      style="display: flex; justify-content: flex-end; margin-top: 10px"
    >
      <el-form-item prop="userId">
        <el-input
          v-model="formData.userId"
          placeholder="请输入用户id"
        ></el-input>
      </el-form-item>

      <el-form-item prop="goodsId">
        <el-input
          v-model="formData.goodsId"
          placeholder="请输入商品id"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button @click="getStrack" type="primary" icon="el-icon-search">查找</el-button>
      </el-form-item>
    </el-form>





  <el-table v-loading='StrackLoading' :data="StrackData" border :header-cell-style="{'text-align':'center'}" :cell-style="{'text-align':'center'}">
    <el-table-column  label="足迹id" prop="id"></el-table-column>
    <el-table-column  label="用户id" prop="userId"></el-table-column>
    <el-table-column  label="商品id" prop="goodsId"></el-table-column>
    <el-table-column  label="添加时间" prop="addTime"></el-table-column>
  </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.page"
      :page-sizes="[1, 20, 30, 50, 100]"
      :page-size="pageInfo.limit"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
    >
    </el-pagination>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  name: 'userStrack',
  componentTitle: '用户足迹',
  data () {
    return {
      StrackLoading:false,
      pageInfo:{
        page:1,
        pageInfo:10,
        total:0
      },
      formData:{
          userId:'',
          goodsId:''
      },

      StrackData:[]
    }
  },
  mounted(){
this.getStrack()
  },
  methods:{
    getStrack(){
      this.StrackLoading=true
      axios({

        url:'http://192.168.200.251:8888/admin/footprint/list',
        method:'get',
        params:{
          page:this.pageInfo.page,
          limit:this.pageInfo.limit,
         ...this.formData
        },
          headers: {
          "shopping-admin-token": sessionStorage.getItem(
            "shopping-admin-token"
          ),
        }
      }).then(res=>{
        this.StrackLoading=false
        this.StrackData=res.data.data.list
        this.pageInfo.total=res.data.data.total

      })
    },

    
 handleSizeChange(value){
   this.pageInfo.limit=value
   this.getStrack()

 },
 handleCurrentChange(){
   this.pageInfo.page=value
   this.getStrack()
 }

  },
}
</script>
